//
//  WCClinicViewController.m
//  WCN
//
//  Created by wsj2015 on 15/9/16.
//  Copyright (c) 2015年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCClinicViewController.h"
#import "WCNMulTextTCell.h"
#import "WCButton.h"
#import "UINavigationItem+Offset.h"
#import "Macros.h"
#import "WCNSwitchTCell.h"
#import "AccountServiceEntity.h"
#import "WCCoreDataStore.h"
#import "WCDefaultManager.h"


static NSString *cellId = @"WCNMulTextTCell";
static NSString *switchId = @"WCNSwitchTCell";
@interface WCClinicViewController ()<UITableViewDelegate,UITableViewDataSource>



@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) AccountServiceEntity *service;
@end

@implementation WCClinicViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title =@"护理门诊";
    self.service = [[WCCoreDataStore shareStore] getAccountService];
    self.service.nurseId = [[WCDefaultManager shareMg] account].stringId;
    
}
- (void)config
{
    WCButton *rightBtn = [WCButton wcButtonWithType:WCButtonTypeSave];
    [rightBtn addTarget:self action:@selector(saveAction) forControlEvents:UIControlEventTouchUpInside];
    [self.navigationItem addRightBarButtonItem:rightBtn];
    
    self.view.backgroundColor = kAppBg;
    
    [self.tableView registerNib:[UINib nibWithNibName:cellId bundle:nil] forCellReuseIdentifier:cellId];
    [self.tableView registerNib:[UINib nibWithNibName:switchId bundle:nil] forCellReuseIdentifier:switchId];

}
- (void)saveAction
{
    


}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return  2;

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSInteger num =0;
    if (section ==0) {
        num =2;
    }else{
        num =3;
    }
    return num;

}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.section == 0 && indexPath.row == 1) {
        WCNSwitchTCell *cell = [tableView dequeueReusableCellWithIdentifier:switchId forIndexPath:indexPath];
        AccountServiceConfigEntity *config = self.service.serviceConfigs[0];
        cell.switchTitle.text = @"服务开关";
        cell.wcSwitch.on = config.isEnabled;
        cell.switchChange = ^(BOOL on){
            config.isEnabled = on;
        };
        return cell;
       
    }
    
        return nil;

}


@end
